package leetcode.median;

import java.util.LinkedList;
import java.util.List;

/**
 * ClassName: $78_Subsets
 * Description:
 * date: 2022-02-18 21:48
 *
 * @author liyifan
 */
public class $78_Subsets {
    List<List<Integer>> res = new LinkedList<>();
    List<Integer> path = new LinkedList<>();
    public List<List<Integer>> subsets(int[] nums) {
        if (nums == null || nums.length == 0){
            return res;
        }
        backtrack(nums, 0);
        return res;
    }

    public void backtrack(int[] nums, int cur){
        if (cur == nums.length) {
            res.add(new LinkedList<>(path));
            return;
        }
        path.add(nums[cur]);
        backtrack(nums, cur + 1);
        path.remove(path.size() - 1);
        backtrack(nums, cur + 1);
    }
}
